function var_dump(obj) {
		   var out = "";
		   for (var i in obj) {
		       out += i + ": " + obj[i] + "\n";
		   }
		   alert(out);      
}

//Toggle control(more-detail click) 
function toggleItems(n){	
	var toggle =new Array();
	var head =  new Array();
	var body =  new Array();
	var foot =  new Array();
	var more_detail =  new Array();
	
	for(i = 0;i<n;i++){
		toggleItem(i);		
	}
	function toggleItem(i){
		checknull = $('more-detail-'+i);
		//alert(a);
		if(checknull != null){		
				
			toggle[i] = false;		
			head[i] = $('result-head-'+i);	
			body[i] = $('result-body-'+i);	
			foot[i] = $('result-foot-'+i);	
			more_detail[i] = $('more-detail-'+i);
			
			body[i].addClass("hidden");
			foot[i].addClass("hidden");			
			
			more_detail[i].addEvent('click',function(){			
				if(!toggle[i]){				
					more_detail[i].innerHTML = "Less details&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
					head[i].removeClass("closed");
					body[i].removeClass("hidden");
					foot[i].removeClass("hidden");
					more_detail[i].removeClass('arrow-down');
					more_detail[i].addClass('arrow-up');
					toggle[i] = true;
				}else{
					more_detail[i].innerHTML = "More details&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
					head[i].addClass("closed");
					body[i].addClass("hidden");
					foot[i].addClass("hidden");
					more_detail[i].addClass('arrow-down');
					more_detail[i].removeClass('arrow-up');
					toggle[i] = false;
				}
			});	
			foot[i].addEvent('click',function(){			
				if(!toggle[i]){
					head[i].removeClass("closed");
					body[i].removeClass("hidden");
					foot[i].removeClass("hidden");
					more_detail[i].removeClass('arrow-down');
					more_detail[i].addClass('arrow-up');
					toggle[i] = true;
				}else{
					head[i].addClass("closed");
					body[i].addClass("hidden");
					foot[i].addClass("hidden");
					more_detail[i].addClass('arrow-down');
					more_detail[i].removeClass('arrow-up');
					toggle[i] = false;
				}
			});
		}												
	}		
}

//Ajax load dropdownlist
function loadlist(selobj,url,nameattr)
{
    $(selobj).empty();
    $.getJSON(url,{},function(data)
    {
        $.each(data, function(i,obj)
        {
            $(selobj).append(
                 $('<option></option>')
                        .val(obj[nameattr])
                        .html(obj[nameattr]));
        });
    });
}

//Ajax paging
function addAjaxNavigator(){
	$$('a.link-text').each(function(el){
		//alert('checked');
		el.addEvent('click', function(e){
            e = new Event(e).stop(); //use this to prevent default
            if(el.id == "gotopage"){
            	var limitstart = $('ajax-limit').value*($('pagenumber').value-1);
    			$('ajax-limitstart').set({value:limitstart});
            }
            else
            	$('ajax-limitstart').set({value:el.id});
            ajaxsubmit();
        });
	});
	if($('pagenumber')!=null){
		$('pagenumber').addEvent('keydown', function(e){
			if(e.key == "enter"){
				e.stop();				
				var limitstart = $('ajax-limit').value*(this.value-1);
				$('ajax-limitstart').set({value:limitstart});
				ajaxsubmit();
			}
	    });	
	}
}

